package com.example.zhxy.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * ClassName: MPconfig
 * Package: com.example.zhxy.config
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-02-13
 * Time: 14:29
 */
@Configuration
@MapperScan("com.example.zhxy.mapper") //扫描接口所在的包
//配置 mybatis-plus 分页插件
public class MPConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //拦截器 配置插件用的
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //在插件对象中 添加内部插件  分页插件叫做  PaginationInnerInterceptor()  第一个参数 是数据库类型
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
